/*
 * Copyright (c) 2025, 大连理工大学 (Dalian University of Technology)
 *
 * Licensed under the Mulan PSL v2.
 * You can use this file according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of the License at
 *
 *     http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. SEE THE MULAN PSL v2
 * FOR MORE DETAILS.
 */

/**
 * @brief   : 提供的数据存储接口
 * @version : 0.1
 * @author  : 武兴创
 * @date    : 2024.10.21
 */
#pragma once

#include "Utility/Configuration/SGParameter.h"

#include "DataStructure/Result/ResultDomains.h"

#include "DBManager/Common/DBManagerExport.h"
#include "DBManager/Common/DomainRequest.h"
#include "DBManager/Common/Trait/InputTrait.h"
#include "DBManager/DBServiceFactory.h"

SG_DBMANAGER_NAMESPACE_OPEN

class DBManager_DECLSPEC IResultDomainsService : public AddTrait<SG::DataStructure::Post::ResultDomains>,
                                                 public FindByIdTrait<SG::DataStructure::Post::ResultDomains>,
                                                 public GetAllIdTrait,
                                                 public CountTrait
{
  public:
    virtual ~IResultDomainsService () {};

    /**
     * @brief 根据你给的request 给你一个 domainid
     *
     * 如果仓库找到了对应的DOMAIN 数据，则返回对应的domainID。
     *
     * 如果仓库没有找到对应的DOMAIN 数据，则会自动创建一个新的DOMAIN数据，然后返回新创建的domainID。
     *
     * ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
     */
    virtual SG::DataStructure::Common::Status GetDomainId (const Post::DomainRequest& request,
                                                           _OUT SG::DataStructure::Common::Id& domainID) = 0;

    /**
     * @brief 根据条件查找domain
     *
     * @param    request
     * @param   [out] domain
     * @author   wxc
     * @date     2024.11.25
     */
    virtual SG::DataStructure::Common::Status Find (const Post::DomainRequest& request,
                                                    _OUT SG::DataStructure::Post::ResultDomains& domain) = 0;

    /// @brief 获取所有domains
    /// @return
    virtual const std::vector<SG::DataStructure::Post::ResultDomains> GetAllData () = 0;

    /**
     * @brief    根据DomainRequest 创建Domain数据
     *
     * @param    request
     * @return
     * @author   wuxingchuang
     * @date     2025.03.06
     */
    virtual SG::DataStructure::Common::Id AddFromRequest (const Post::DomainRequest& request) = 0;
};

template <>
std::shared_ptr<IResultDomainsService> DBManager_DECLSPEC DBServiceFactory::get ();

SG_DBMANAGER_NAMESPACE_CLOSE
